package utils.math;

import figuras.PuntoVector;

public class MathFlowers {

	public static PuntoVector multiplicar(double[] d, PuntoVector point) {
		double x = d[0] * point.getX() + d[4] * point.getY() + d[8]
				* point.getZ() + d[12] * point.getPv();
		double y = d[1] * point.getX() + d[5] * point.getY() + d[9]
				* point.getZ() + d[13] * point.getPv();
		double z = d[2] * point.getX() + d[6] * point.getY() + d[10]
				* point.getZ() + d[14] * point.getPv();
		double pv = point.getPv();
		return new PuntoVector(x, y, z, pv);
	}

	public static void print(double[] d) {
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				System.out.print(d[i * 4 + j] + " ");
		System.out.println("");
	}

	public static double[] multiplicar(double[] a, double[] b){
		double[] d = new double[a.length];
		d[0] = a[0]*b[0]+a[4]*b[1]+a[8]*b[2]+a[12]*b[3];
		d[1] = a[1]*b[0]+a[5]*b[1]+a[9]*b[2]+a[13]*b[3];
		d[2] = a[2]*b[0]+a[6]*b[1]+a[10]*b[2]+a[14]*b[3];
		d[3] = a[3]*b[0]+a[7]*b[1]+a[11]*b[2]+a[15]*b[3];
		d[4] = a[0]*b[4]+a[4]*b[5]+a[8]*b[6]+a[12]*b[7];
		d[5] = a[1]*b[4]+a[5]*b[5]+a[9]*b[6]+a[13]*b[7];
		d[6] = a[2]*b[4]+a[6]*b[5]+a[10]*b[6]+a[14]*b[7];
		d[7] = a[3]*b[4]+a[7]*b[5]+a[11]*b[6]+a[15]*b[7];
		d[8] = a[0]*b[8]+a[4]*b[9]+a[8]*b[10]+a[12]*b[11];
		d[9] = a[1]*b[8]+a[5]*b[9]+a[9]*b[10]+a[13]*b[11];
		d[10] = a[2]*b[8]+a[6]*b[9]+a[10]*b[10]+a[14]*b[11];
		d[11] = a[3]*b[8]+a[7]*b[9]+a[11]*b[10]+a[15]*b[11];
		d[12] = a[0]*b[12]+a[4]*b[13]+a[8]*b[14]+a[12]*b[15];
		d[13] = a[1]*b[12]+a[5]*b[13]+a[9]*b[14]+a[13]*b[15];
		d[14] = a[2]*b[12]+a[6]*b[13]+a[10]*b[14]+a[14]*b[15];	
		d[15] = a[3]*b[12]+a[7]*b[13]+a[11]*b[14]+a[15]*b[15];
		return d;
	}
}
